package model.tree
{
	import constants.GlobalConstants;
	
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.external.ExternalInterface;
	import flash.net.URLRequest;
	
	import mx.controls.Image;
	
	import valueObjects.VOPicture;

	public class PictureNode extends EventDispatcher
	{
		[Bindable]
		public var pictureData:VOPicture;
		[Bindable]
		public var icon:DisplayObject;
		
		private var loader:Loader;
		private var request:URLRequest;
		
		public function PictureNode(pictureData:VOPicture)
		{
			
			// storing teh picture data
			this.pictureData = pictureData;
			
			// load the image
			imgView();
			
			
		}
		
		public function imgView():void
		{
			// downloading teh picture
			/********szabi********/
			//var image_path:String = GlobalConstants.LOCAL_IMAGE_URL  + pictureData.userId +
								//"/" + pictureData.tripId + "/" + pictureData.placeId + "/" + pictureData.id;
			
			var image_path:String = GlobalConstants.LOCAL_IMAGE_URL  + pictureData.userId +
				"/" + pictureData.tripId + "/" + pictureData.placeId + "/" + pictureData.title;
			
			loader=new Loader();
			request=new URLRequest(image_path);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
			loader.load(request);
			
			
		}
		
		private function onComplete(e:Event):void {
			// trace 
			icon = loader.content;
			
		
		}
	}
}